<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <p>商品列表</p>
    <ol>
        <li></li>
    </ol>
    <div>
        <p>购物车</p>
    <ul>
        <li>
            商品名称 <button>-</button><input type="text" value="1"><button>+</button>
        </li>
    </ul>
</div>
    <script>
        //创建购物车
        class Cart {
            constructor(){
                this.goodsList=[]
            }
            //添加购物车
            add(goods){
                this.goodsList.push(goods)
            }
            //移除购物车
            del(id){
                this.goodsList.splice(this.goodsList.findIndex( item=>item.id==id),1)
            }
            setdom(){
                let ul = document.querySelector('ul')
                let lis = ''
                this.goodsList,forEach(XMLSerializer )
            }
        }
    </script>
</body>
</html>